package com.nursing;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import java.io.IOException;

@SpringBootApplication

public class Application {

    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);

        // 项目在windows环境下启动，自动打开swagger页面，方便调试（默认浏览器）
        try {
            // 要打开的网页的 URL
            String url = "http://localhost:8080/swagger-ui/index.html";
            // 执行命令行命令
            String os = System.getProperty("os.name").toLowerCase();
            if (os.contains("win")) {
                Runtime.getRuntime().exec(new String[]{"cmd", "/c", "start", url});
            }
        } catch (IOException e) {
            e.printStackTrace();
        }


        // 打开浏览器并访问 Swagger 页面
//        String url = "http://localhost:8080/swagger-ui/index.html";
//        try {
//
//            Desktop desktop = Desktop.getDesktop();
//            desktop.browse(java.net.URI.create(url));
//        } catch (java.io.IOException e) {
//            System.out.println("无法打开浏览器：" + e.getMessage());
//        }
    }

}
